home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / emstools.arc / EMMLIB.ARC / EMM27_A.ASM < prev    next >
Assembly Source File  |  1990-02-04  |  9KB  |  151 lines

  1. ;-----------------------------------------------------------------------------;
  2. ;      MODULE NAME:   EMM27_A.ASM                                             ;
  3. ;                                                                             ;
  4. ;    FUNCTION NAME:   alloc_std_pages                                         ;
  5. ;                                                                             ;
  6. ;      DESCRIPTION:   This function allocates the number of standard size     ;
  7. ;                     (16K bytes) pages that the operating system requests    ;
  8. ;                     and assigns a unique EMM handle to these pages.  The    ;
  9. ;                     EMM handle owns these pages until the application       ;
  10. ;                     deallocates them.                                       ;
  11. ;                                                                             ;
  12. ;                     This function allows you to allocate zero pages to a    ;
  13. ;                     handle, unlike the alloc_pages function.                ;
  14. ;                                                                             ;
  15. ;                     Note:                                                   ;
  16. ;                        This note affects expanded memory manager            ;
  17. ;                        implementers and operating system developers only.   ;
  18. ;                        Applications should not use the following            ;
  19. ;                        characteristic of the memory manager.  An            ;
  20. ;                        application violating this rule will be incompatible ;
  21. ;                        with future versions of Microsoft's operating        ;
  22. ;                        systems and environments.                            ;
  23. ;                                                                             ;
  24. ;                        To be compatible with this specification, an         ;
  25. ;                        expanded memory manager will provide a special       ;
  26. ;                        handle which is available to the operating system    ;
  27. ;                        only.  This handle will have a value of 0 and        ;
  28. ;                        will have a set of pages allocated to it when the    ;
  29. ;                        expanded memory manager driver installs.  The pages  ;
  30. ;                        that the memory manager will automatically allocate  ;
  31. ;                        to handle 0 are those that it has mapped into        ;
  32. ;                        conventional memory.                                 ;
  33. ;                                                                             ;
  34. ;                        An operating system won't have to invoke the         ;
  35. ;                        alloc_std_pages function to obtain this handle       ;
  36. ;                        because it can assume the handle already exists and  ;
  37. ;                        is available for use immediately after the expanded  ;
  38. ;                        memory device driver installs.  When an operating    ;
  39. ;                        system wants to use this handle, it uses the special ;
  40. ;                        handle value of 0. The operating system will be able ;
  41. ;                        to invoke any EMM function using this special handle ;
  42. ;                        value.  To allocate pages to this handle, the        ;
  43. ;                        operating system need only invoke realloc_pages      ;
  44. ;                        function.                                            ;
  45. ;                                                                             ;
  46. ;                        There are two special cases for this handle:         ;
  47. ;                        1. alloc_std_pages: when invoked, must never return  ;
  48. ;                           zero as a handle value.  Applications must always ;
  49. ;                           invoke alloc_std_pages to allocate pages and      ;
  50. ;                           obtain a handle which identifies the pages which  ;
  51. ;                           belong to it.  Since alloc_std_pages never        ;
  52. ;                           returns a handle value of zero, an application    ;
  53. ;                           will never gain access to this special handle.    ;
  54. ;                                                                             ;
  55. ;                        2. dealloc_pages: if the operating system uses it to ;
  56. ;                           deallocate the pages which are allocated to this  ;
  57. ;                           handle, the pages the handle owns will be         ;
  58. ;                           returned to the manager for use.  But the handle  ;
  59. ;                           will not be available for reassignment.  The      ;
  60. ;                           manager should treat a deallocate pages function  ;
  61. ;                           request for this handle the same as a reallocate  ;
  62. ;                           pages function request, where the number of pages ;
  63. ;                           to reallocate to this handle is zero.             ;
  64. ;                                                                             ;
  65. ;           PASSED:   std_page_count:                                         ;
  66. ;                        is the number of standard pages the operating system ;
  67. ;                        wants to allocate.                                   ;
  68. ;                                                                             ;
  69. ;                     &handle:                                                ;
  70. ;                        is a far pointer to a unique handle which the memory ;
  71. ;                        manager will assign to the block of pages allocated  ;
  72. ;                        to the operating system.                             ;
  73. ;                                                                             ;
  74. ;         RETURNED:   status:                                                 ;
  75. ;                        is the status EMM returns from the call.  All other  ;
  76. ;                        returned results are valid only if the status        ;
  77. ;                        returned is zero.  Otherwise they are undefined.     ;
  78. ;                                                                             ;
  79. ;                     handle:                                                 ;
  80. ;                        is a unique handle which the memory manager will     ;
  81. ;                        assign to the block of pages allocated to the        ;
  82. ;                        operating system.  The operating system must use     ;
  83. ;                        this EMM handle as a parameter in any function that  ;
  84. ;                        requires it.  Up to 255 handles may be obtained.     ;
  85. ;                        The alloc_pages and alloc_std_pages functions must   ;
  86. ;                        share the same 255 handles.                          ;
  87. ;                                                                             ;
  88. ;                        For all functions using this handle, the length of   ;
  89. ;                        the physical and logical pages allocated to it are   ;
  90. ;                        standard length (that is, 16K bytes).                ;
  91. ;                                                                             ;
  92. ; C USE CONVENTION:   unsigned int status;                                    ;
  93. ;                     unsigned int std_page_count;                            ;
  94. ;                     unsigned int handle;                                    ;
  95. ;                                                                             ;
  96. ;                     status = alloc_std_pages (std_page_count,               ;
  97. ;                                               &handle);                     ;
  98. ;-----------------------------------------------------------------------------;
  99. .XLIST
  100. PAGE    60,132
  101.  
  102. IFDEF SMALL
  103.    .MODEL SMALL, C
  104. ENDIF
  105. IFDEF MEDIUM
  106.    .MODEL MEDIUM, C
  107. ENDIF
  108. IFDEF LARGE
  109.    .MODEL LARGE, C
  110. ENDIF
  111. IFDEF COMPACT
  112.    .MODEL COMPACT, C
  113. ENDIF
  114. IFDEF HUGE
  115.    .MODEL HUGE, C
  116. ENDIF
  117.  
  118. INCLUDE emmlib.equ
  119. INCLUDE emmlib.str
  120. INCLUDE emmlib.mac
  121. .LIST
  122. .CODE
  123.  
  124. alloc_std_pages        PROC                                                  \
  125.             std_page_count:WORD,                                  \
  126.             ptr_handle:FAR PTR WORD
  127.  
  128.     ;---------------------------------------------------------------------;
  129.     ;   do;                                                               ;
  130.     ;   .   allocate the number of specified STANDARD pages from EMM;     ;
  131.     ;---------------------------------------------------------------------;
  132.     MOVE        AX, alloc_standard_pages_fcn
  133.     MOVE        BX, std_page_count
  134.     INT         EMM_int
  135.  
  136.     ;---------------------------------------------------------------------;
  137.     ;   .   pass the handle back to the caller;                           ;
  138.     ;---------------------------------------------------------------------;
  139.     MOVE        ES:BX, ptr_handle
  140.     MOVE        ES:[BX], DX
  141.  
  142.     ;---------------------------------------------------------------------;
  143.     ;   .   return (EMM status);                                          ;
  144.     ;   end;                                                              ;
  145.     ;---------------------------------------------------------------------;
  146.     RET_EMM_STAT    AH
  147.  
  148. alloc_std_pages        ENDP
  149.  
  150. END
  151.